/**
 * Copyright (c) iwindplus Technologies Co., Ltd.2024-2030, All rights reserved.
 */

package com.iwindplus.aider.web.service.impl;

import com.iwindplus.base.domain.dto.UserCaptchaValidDTO;
import com.iwindplus.base.domain.vo.ApiSignVO;
import com.iwindplus.base.domain.vo.ResultVO;
import com.iwindplus.base.domain.vo.UserBindVO;
import com.iwindplus.base.domain.vo.UserCaptchaValidVO;
import com.iwindplus.base.operate.service.OperateService;
import com.iwindplus.mgt.client.power.UserClient;
import com.iwindplus.mgt.client.system.AppCertClient;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 操作业务层接口实现类.
 *
 * @author zengdegui
 * @since 2023/07/30 22:31
 */
@Slf4j
@Component
public class OperateServiceImpl implements OperateService {

    @Resource
    private AppCertClient appCertClient;

    @Resource
    private UserClient userClient;

    @Override
    public ApiSignVO getApiSign(String accessKey) {
        final ResultVO<ApiSignVO> result = this.appCertClient.getByAccessKey(accessKey);
        result.errorThrow();
        return result.getBizData();
    }

    @Override
    public UserBindVO checkUserBind(Long userId) {
        final ResultVO<UserBindVO> result = this.userClient.checkUserBind(userId);
        result.errorThrow();
        return result.getBizData();
    }


    @Override
    public UserCaptchaValidVO checkCaptchaByUserId(UserCaptchaValidDTO entity) {
        final ResultVO<UserCaptchaValidVO> result = this.userClient.checkCaptchaByUserId(entity);
        result.errorThrow();
        return result.getBizData();
    }
}
